package oop.ex1.filters;

import java.io.File;
/**
 * a filter that checks if the file is executable
 * @author danalmog
 * @author danielshalev
 */
public class Executable extends PermissionDependent {
	
	/**
	 * a constructor that sends the relevant parameters to its super
	 * @param permission the executable value we want to check
	 * @param hasNot determines if the filter is NOT filter
	 * @throws FilterYesNoExeption indicates that the argument is neither YES nor NO
	 */
	public Executable(String permission,boolean hasNot) throws FilterYesNoExeption {
		super(permission,hasNot);
	}
	
	
	/**
	 * checks if the file has the desired executable state
	 * @param pathname the file to check 
	 * @return true if the file is in the relevant state and false otherwise
	 */
	public boolean accept(File pathname){
		if(getPermit() && pathname.canExecute())
			return true;
		if(!getPermit() && !pathname.canExecute())
			return true;
		return false;
	}

}
